## basechart.py
##
## PacStats: Statistical charts about Archlinux pacman activity
## Copyright (C) 2010 Angelo "Encelo" Theodorou <encelo@gmail.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##


try:
	import matplotlib.figure as f
	from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas
	from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar
except ImportError:
	print('Matplotlib is missing!')
	exit(-1)


class BaseChart:
	"""A skeleton class for a chart to inherit from"""
	def __init__(self, database):
		self._database = database
		self._transactions = database.transactions
		self._packages = database.packages

		self._name = ''
		self._description = ''
		self._version = ''


	def get_name(self):
		return self._name

	def get_description(self):
		return self._description

	def get_version(self):
		return self._version


	def generate(self):
		"""Generate the chart"""
		pass
		

	def attach(self, canvas):
		"""Attach the chart to a canvas class"""

		self._canvas = canvas
		self._canvas.figure.clear()
		self.generate()
		self._canvas.draw()


	def detach(self):
		"""Detach the chart from the canvas class"""

		self._canvas = None
